﻿@model cloudscribe.Core.Web.ViewModels.RoleAdmin.RoleListViewModel
@inject ICoreThemeHelper themeHelper
@inject IStringLocalizer<CloudscribeCore> sr
@inject IOptions<SiteConfigOptions> setupOptionsAccessor
@{
    var setupOptions = setupOptionsAccessor.Value;
    ViewData["BodyClass"] = "admin-section role-index";
    var themeSettings = themeHelper.GetThemeSettings();
    if (themeSettings.AdminSideNavExpanded) { ViewData["SideNavToggle"] = "show"; }
    ViewData["SideNavVisible"] = true;
}

<h2>@ViewData["Title"]</h2>
<p>
    <a class="btn btn-sm btn-primary" asp-action="RoleEdit" asp-controller="RoleAdmin" asp-route-siteId="@Model.SiteId">@sr["New Role"]</a>
</p>
<ul class=" list-group">
    @foreach (var item in Model.SiteRoles.Data)
    {
        <li class=" list-group-item d-flex flex-wrap">
            <h3 class="h4">
                @Html.DisplayFor(modelItem => item.RoleName)
                &nbsp;
            </h3>
            <div role="group">
                <span class="btn btn-outline-primary ">
                    <a asp-action="RoleMembers"
                       asp-controller="RoleAdmin"
                       asp-route-siteId="@item.SiteId"
                       asp-route-roleId="@item.Id">@sr["Members"]</a>
                    <span class="badge">@Html.DisplayFor(modelItem => item.MemberCount)</span>
                </span>
                @if (item.IsDeletable(setupOptions.RolesThatCannotBeDeleted))
                {
                    <a class="btn btn-primary" asp-action="RoleEdit" asp-controller="RoleAdmin"
                       asp-route-siteId="@Model.SiteId"
                       asp-route-roleId="@item.Id">@sr["Edit"]</a>
                }

            </div>
        </li>
    }
</ul>
<cs-pager asp-action="Index" asp-controller="RoleAdmin"
          asp-route-siteId="@Model.SiteId"
          asp-route-pageSize="@Model.SiteRoles.PageSize"
          cs-paging-pagesize="@Model.SiteRoles.PageSize"
          cs-paging-pagenumber="@Model.SiteRoles.PageNumber"
          cs-paging-totalitems="@Model.SiteRoles.TotalItems"
          cs-first-page-title='@sr["First Page"]'
          cs-last-page-title='@sr["Last Page"]'
          cs-previous-page-title='@sr["Previous page"]'
          cs-next-page-title='@sr["Next page"]'
          cs-pager-ul-class="pagination d-flex flex-wrap"
          cs-pager-li-current-class="page-item active"
          cs-pager-li-other-class="page-item"
          cs-pager-li-non-active-class="page-item disabled"
          cs-pager-link-current-class="page-link"
          cs-pager-link-other-class="page-link"></cs-pager>
@section SideNav {
    <partial name="AdminSideNav" />
}
@section Toolbar{
    <partial name="AdminSideNavToggle" />
}
@section scripts {
    <partial name="AdminSideNavScripts" />
}
